#include <cmath>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

#include "uthash.h"

int findNthDigit(int n);

int main()
{
	return 0;
}

int findNthDigit(int n)
{
	int digit = 1;
	long base = 9, start_num = 1, cond = base * digit;
	while (n > cond) {
		n -= digit * base;
		base *= 10;
		start_num *= 10;
		digit++;
		cond = base * digit;
	}

	long num = start_num + (n - 1) / digit;
	int idx = (n - 1) % digit;

	num %= (long)(pow(10, digit - idx));
	num /= (long)(pow(10, digit - idx - 1));
	return num;
}
